/**
 * 基础菜单 商品管理
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    </el-breadcrumb>


<el-form :model="userFrom" :rules="rules" ref="userFrom" label-width="100px" class="demo-userFrom">
        <el-form-item label="商店名称" prop="storeName">
            <el-input type="text" v-model="userFrom.storeName" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="开门时间" prop="storeStarttime">
            <el-input type="text" v-model="userFrom.storeStarttime" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="关门时间" prop="storeClosetime">
            <el-input type="text" v-model="userFrom.storeClosetime" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="地址" prop="storeAddress">
            <el-input type="text" v-model="userFrom.storeAddress" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="电话" prop="storeTel">
            <el-input type="text" v-model="userFrom.storeTel" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="门店照片" prop="storePic">
                      <el-upload
            class="upload-demo"
            ref="upload"
            action="http://localhost:9000/ses/mdStore/upload"
            :file-list="fileList"
            :auto-upload="false"
            :on-change="changeFile"
            :on-success="handleUploadSuccess"
          >
            <el-button slot="trigger" size="small" type="primary"
              >选取文件</el-button
            >
            <el-button
              style="margin-left: 10px"
              size="small"
              type="success"
              @click="submitUpload"
              >上传到服务器</el-button
            >
          </el-upload>
        </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="insertStore()">加盟申请</el-button>
      </el-form-item>


</el-form>


  </div>
</template>

<script>
import * as store from "@/api/store.js";

export default {
  data() {
    return {
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      title: '添加',
      userFrom: {
        storeId:"",
        storeName:"",
        storeStarttime:"",
        storeClosetime:"",
        storeScore:"",
        storeNum:"",
        storeAddress:"",
        storeTel:"",
        storePic:"",
        storeStatus:""

      },
      fileList:[],
      // rules表单验证
      rules: {

      },
      formInline: {
        page: 1,
        limit: 10,
        varLable: '',
        varName: '',
        token: localStorage.getItem('logintoken')
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
 
  },
  /**
   * 数据发生改变
   */

  /**
   * 创建完毕
   */
  created() {
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {

    
    check(index,row) {
      console.log(row.storeId)
      if(row.storeStatus==0){
        row.storeStatus=1
      }else{
        row.storeStatus=0
      }
      store.check(row)
        .then((res) => {
          this.$message({
              type: "success",
              message: "审核加盟成功！",
          });          
        })
        .catch((res) => {
          this.$message.error("失败，请稍后再试！");
        });
    },

    insertStore() {
      store.insert(this.userFrom)
        .then((res) => {
          if (res.data.code == 200) {
                this.editFormVisible = false;
                this.loading = false;
                this.$message({
                  type: "success",
                  message: "正在申请加盟",
                });
          }
          if (res.data.code == 300) {
                this.editFormVisible = false;
                this.loading = false;
                this.$message({
                  type: "success",
                  message: "重复申请加盟",
                });
          }
        });
    },


    submitUpload(){//上传文件
        this.$refs.upload.submit();
    },
    changeFile(file,fileList){
        console.log("---"+fileList[fileList.length-1])
       this.fileList = [];
       this.fileList.push(fileList[fileList.length-1]);
    },
    handleUploadSuccess(response){
        console.log("------"+response.data);
        if(response && response.code == 200){
            this.userFrom.storePic = response.data;
        }
    },



  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 